![]() |
LISTS 01 |
OPENING QUESTIONS: Let's say it was 1880 and you were working with prominent astronomers of the day and you are working to catalog astronomical phenomena. What steps would you follow to do that? (please discuss with your groups and write your responses individually using full sentences.) LEARNING TARGET: I will be able to:
after today's class WORK O' THE DAY: So far we've dealt with 'variables' to hold data. Sometimes we use the built-in variable 'answer' to hold data that we request from our user. Sometimes we define our own variable to hold data that we need to process. But, (up until now at least) we've been working with variables that hold only one piece of data. What happens if we need to hold more than one piece of data? The answer is "lists" (usually called 'arrays' in most programming languages). ═══════════════════════════ Now let's return to our opening question... let's say you are tackling that same problem, but this time you are using SNAP. Here's how we might start out making a list for our catalog of features in our solar system... starting with planets:
Take a moment to recreate that IN A BRAND NEW program in SNAP. Here's How:
Then we might recollect that there are comets in our solar system, so let's start a list for those (ack! we can only remember one name for a comet, no worries, let's just start with that)
Your screen should look like this:
Now you recollect that there are asteroids out there in our solar system (LOTS of them, actually) but you don't remember any of their names. No worries, let's just put a 'place holder' list for now:
The kind of oddball part of lists in SNAP is we can't really name our lists (which I find personally rather confusing) Any suggestions on how we can assign a name to a list? (Take a few moments to discuss with your group) ═══════════════════════════ In order to make the list useful, we have to have some way to refer to it.... and in SNAP, the way to do that is to create variables for each of our lists, and then link those names to the lists: So far we have 3 different types of objects found in our solar system... what are they?
So it makes sense that we should use those categories to create variables, and then set THOSE variables to our lists:
NOTICE how important it is to make the list correspond with the category of data that it holds. It would be a lot harder if we just made an "Objects of the Solar System" list and populated with a bunch of stuff. ═══════════════════════════ By choosing our lists and our variables appropriately, we can bring a great deal of order to our data. Please now work with your group to create a NEW list for some sort of something in our solar system that we haven't put on our list yet (Think "Luna" hint hint hint. ═══════════════════════════ Now let's have some fun with lists.... work on adding, deleting and inserting various items into your list. Pay *particular* attention to the difference between the 'insert' and the "add" functions. ═══════════════════════════
Microsoft reminds me to make sure we all do THIS survey! CLOSING QUESTION: Please take out a sheet of paper and write descriptions for each numbered block of the following code (Notice also that if you drag your comments to a particular block, SNAP automatically draws a line to connect your comment to that individual block)
If time permits -- Write a program that asks your user for input and takes that input and puts it into one of your lists. HOMEWORK: |